export default function useRulesTodo(data) {
	const mobileReg = /^1(3|4|5|6|7|8|9)\d{9}$/;
	const {
		vCode
	} = data;
	const validateLoginName = (rule, val) => {
		if (!val || val.length < 6) return '用户名长度不正确，至少为6个字符'
		return true
	};
	const validatePhone = (rule, val) => {
		if (!mobileReg.test(val)) return '手机号码格式不正确'
		return true
	};
	const validateVcode = (rule, val) => {
		//验证验证码
		console.log(vCode)
		if (val !== vCode) return '请输入正确的验证码'
		return true;
	};
	const userRules = {
		loginName: {
			rules: [{
				required: true,
				errorMessage: "账户名不能为空",
				trigger: 'blur'

			}, {
				validateFunction: validateLoginName,
				trigger: 'blur'
			}]
		},
		password: {
			rules: [{
				required: true,
				errorMessage: "密码不能为空",
				trigger: 'blur'
			}]
		},
		phone: {
			rules: [{
				required: true,
				'errorMessage': "手机号不能为空",
				trigger: 'blur',
				validateFunction: validatePhone,
			}]
		},
		vCode: {
			rules: [{
				required: true,
				'errorMessage': "验证码不能为空",
				trigger: 'blur',
				validateFunction: validateVcode,
			}]
		}

	};

	return {
		userRules,
	}
}